﻿using System;

namespace ExFlash.Tags
{
    public class DefineBitsJpeg3Tag : DefineBitsJpeg2Tag
    {
        public UInt32 AlphaDataOffset
        {
            get;
            protected set;
        }

        public Byte[] BitmapAlphaData
        {
            get;
            protected set;
        }

        protected DefineBitsJpeg3Tag(TagCodes code,int len, int offset)
            : base(code, len,offset)
        {

        }

        public DefineBitsJpeg3Tag(int len, int offset)
            : this(TagCodes.DefineBitsJPEG3,len,offset)
        {

        }
        
        public override void SwfDeserialize(BinaryBitReader reader)
        {
            long startIndex = reader.Position;

            CharacterId = reader.ReadUInt16();

            AlphaDataOffset = reader.ReadUInt32();

            ImageData = new Byte[AlphaDataOffset];
            reader.Read(ImageData, 0, (int)AlphaDataOffset);

            long alphaLen = TagLength - (reader.Position - startIndex);
            BitmapAlphaData = new Byte[alphaLen];
            reader.Read(BitmapAlphaData,0,(int)alphaLen);
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }
    }
}
